<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>推广中心</title>
        <script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
		<link rel="stylesheet" href="__INDEX__/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/css/member.css" />
		<link rel="stylesheet" href="__INDEX__/css/wallet.css" />
		<link rel="stylesheet" href="__INDEX__/css/hykcz.css" />
	</head>
	<style>
		.tixian {
			float: right;
			margin-top: -43px;
			margin-right: 1px;
			background: #2783e7;
			color: white;
			padding: .1rem .3rem .2rem;
		}
		
		.tanchubox {
			height: 300px;
		}
		
		input[type=number] {
			width: 60%;
		}
		
		.sytc_qrbtnbox {
			position: absolute;
			width: 100%;
			height: 45px;
			background: white;
			display: table;
			border-top: 1px solid #E1E1E1;
			bottom: 0px; 
			left: 0;
		    right: 0;
		}
		
		.sytc_qrbtnbox a {
			display: table-cell;
			vertical-align: middle;
			border-right: 1px solid #E1E1E1;
			text-align: center;
			color: #555555;
		}
		
		.mui-icon {
			line-height: inherit;
		}
		.mask { 
		    background: rgba(0,0,0,.5); 
		}
	</style>

	<body> 
		<header class="mui-bar mui-bar-nav">
			<a class=" mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
			<h1 class="mui-title">推广中心</h1>
		</header>
		<div class="mui-content tgewm_content">
			<div class="liansd_tjbox">
				<div class="liansd_ze">
					<a href="yj_record">
						<p>累计佣金收入(元)</p>
						<p class="pri" id="total_money">{$ywy_yj ? $ywy_yj : '0.00'}</p>
					</a>
				</div>
				<ul class="liansd_tjlist clearfix">
					<li>
						<a href="friends_list">
							<p>我的会员(人)</p>
							<p class="pri" id="my_users">{$user.count?$user.count : 0}</p>
						</a>
					</li>
					<li>
						<a href="yj_record">
							<p>佣金余额(元)</p>
							<p class="pri" id="count_money">{$user.yj?$user.yj : 0.00}</p>
						</a>
						<span class="tixian">提现</span>
					</li>
				</ul>
			</div>
			<div class="tgewm_box">
				<div class="tgerweim" style="width: 176px; height: 186px;">
					<div id="qrcode"></div>
					<img id="code_img" src="" style="display: none;">
				</div>
				<div class="tgewmtip">扫一扫，注册成为会员</div>
				<div class="tgewm_tip">会员享积分，折扣更多，优惠更多！</div>
			</div>
		</div>
		<!--提现弹框-->
		<form method="post" id="my_form">
			<div class="tanchubox" style="display: none;">
				<div class="zhuanz_item">
					<div class="top clearfix">
						<label>提现金额</label>
						<input type="number" name="yj" id='yj' placeholder="请输入提现金额" />
					</div>
				</div>
				<div class="zhuanz_item">
					<div style="font-size: 10px;margin-top: 10px;">当前可提现佣金：{$user.yj?$user.yj : 0.00}</div>	
				</div>
				<div class="sytc_qrbtnbox">
					<a href="#" class="shuax" id="change_but" onclick="hide_tc()">取消</a>
					<a href="#" class="shuax" id="btn">确定</a>
				</div>
				<div class="close" onclick="hide_tc()"><span class="mui-icon mui-icon-closeempty"></span></div>
			</div>
			<div class="mask" style="display: none;"></div>
		</form>
		<script type="text/javascript" src="__INDEX__/js/jquery.min.js"></script> 
		<script type="text/javascript" src="__INDEX__/js/jquery.qrcode.js"></script>
		<script type="text/javascript" src="__INDEX__/js/utf.js"></script> 
	</body>

</html>
<script>
	$("#qrcode").qrcode({
		render: "canvas", //设置渲染方式，有table和canvas，使用canvas方式渲染性能相对来说比较好
		text: "{$code_url}", //扫描二维码后显示的内容,可以直接填一个网址，扫描二维码后自动跳向该链接
		width: "170", //二维码的宽度
		height: "180", //二维码的高度
		background: "#ffffff", //二维码的后景色
		foreground: "#000000", //二维码的前景色
		src: "{$Think.session.user_info.logo}" //二维码中间的图片
	});

	$('.tixian').click(function() {
		$('.tanchubox').show();
		$('.mask').show();
	});
	//关闭弹层框和笼罩层
	function hide_tc(){
	 	$('.tanchubox').hide();
	 	$('.mask').hide(); 
	 	$('#yj').val(''); 
	}
	
	$('#btn').click(function(){
		var yj = $('#yj').val(); 
		var user_yj = "{$user.yj}";  
		if(!yj){
			mui.toast('请输入提现金额');
			return false;
		}
		if(parseInt(yj) > parseInt(user_yj)){
    		mui.toast('佣金不足，请重新填写提现佣金');
			return false;
        } 
        if(parseFloat(yj) % 100 != 0){
			mui.toast("提现金额必须是100的整数倍"); 
			return false;
		}
		$.ajax({
			url: "{:url('index/member/yj')}",
			data: $('#my_form').serialize(),
			type: 'post',
			async: false,
			success: function(res) {  
			    if(res.code == 1) {
			    	hide_tc();
                    mui.toast(res.msg); 
                } else {
                   mui.toast(res.msg);
                }
			}
		})
	});
</script>